{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "858005b1",
   "metadata": {},
   "source": [
    "# 查询字典的方法help（）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "1c4ab59d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:xiaoming\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'i': 2, 'a': 1, 'o': 1}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vowels = [\"a\",\"e\",\"i\",\"o\",\"u\"]\n",
    "word = input(\"Provide a word to search for vowels:\")\n",
    "found = {}\n",
    "\n",
    "for letter in word:\n",
    "    if letter in vowels:\n",
    "        found.setdefault(letter,0)  \n",
    "        found[letter] +=1\n",
    "found"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "abceeba4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function fromkeys:\n",
      "\n",
      "fromkeys(iterable, value=None, /) method of builtins.type instance\n",
      "    Create a new dictionary with keys from iterable and values set to value.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(found.fromkeys)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "30a865a4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function setdefault:\n",
      "\n",
      "setdefault(key, default=None, /) method of builtins.dict instance\n",
      "    Insert key with a value of default if key is not in the dictionary.\n",
      "    \n",
      "    Return the value for key if key is in the dictionary, else default.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(found.setdefault)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b7bbe54c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function pop:\n",
      "\n",
      "pop(...) method of builtins.dict instance\n",
      "    D.pop(k[,d]) -> v, remove specified key and return the corresponding value.\n",
      "    If key is not found, d is returned if given, otherwise KeyError is raised\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(found.pop)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "9a4f49ec",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function keys:\n",
      "\n",
      "keys(...) method of builtins.dict instance\n",
      "    D.keys() -> a set-like object providing a view on D's keys\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(found.keys)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "3d4316c6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function values:\n",
      "\n",
      "values(...) method of builtins.dict instance\n",
      "    D.values() -> an object providing a view on D's values\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(found.values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "302cbaba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function popitem:\n",
      "\n",
      "popitem() method of builtins.dict instance\n",
      "    Remove and return a (key, value) pair as a 2-tuple.\n",
      "    \n",
      "    Pairs are returned in LIFO (last-in, first-out) order.\n",
      "    Raises KeyError if the dict is empty.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(found.popitem)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "842fb55c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function update:\n",
      "\n",
      "update(...) method of builtins.dict instance\n",
      "    D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.\n",
      "    If E is present and has a .keys() method, then does:  for k in E: D[k] = E[k]\n",
      "    If E is present and lacks a .keys() method, then does:  for k, v in E: D[k] = v\n",
      "    In either case, this is followed by: for k in F:  D[k] = F[k]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(found.update)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "67a54a30",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function copy:\n",
      "\n",
      "copy(...) method of builtins.dict instance\n",
      "    D.copy() -> a shallow copy of D\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(found.copy)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ec1cc8ff",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
